from datetime import datetime

import pytz

from app.core.config import settings


def get_timezone():
    return pytz.timezone(settings.TIMEZONE)


def convert_to_local(dt: datetime) -> datetime:
    if dt.tzinfo is None:
        dt = pytz.UTC.localize(dt)
    return dt.astimezone(get_timezone())


def convert_to_utc(dt: datetime) -> datetime:
    if dt.tzinfo is None:
        dt = get_timezone().localize(dt)
    return dt.astimezone(pytz.UTC)


def now() -> datetime:
    return datetime.now(get_timezone())
